﻿<%@ Page Title="Category Wise Job Search -" Language="C#" MasterPageFile="~/Site.master"
    AutoEventWireup="true" CodeFile="CategoryWiseJobSearch.aspx.cs" Inherits="Job_CategoryWiseJobSearch" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
    <%: Styles.Render("~/CategoryWiseJobSearch") %>
    <script type="text/javascript">
        $(document).ready(InIEvent);

        function InIEvent() {
            SearchWhatText();
            SearchWhereText();
            $('ul.ui-autocomplete').css("display", "none");
        }

        $(document).ajaxStop(function () {
        });

        function SearchWhatText() {
            $("#<%=txtWhat.ClientID %>").autocomplete({
                //autoFocus: true,
                source: function (request, response) {
                    var txt = $("#<%=txtWhat.ClientID %>").val();
                    if (txt.length > 1) {
                        $.ajax({
                            url: "CategoryWiseJobSearch.aspx/GetAutoCompleteWhatData",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json; charset=utf-8",
                            cache: false,
                            async: false,
                            data: JSON.stringify({ txt: txt }),
                            dataFilter: function (data) { return data; },
                            success: function (data) {
                                response($.map(data.d, function(item) {
                                    return {
                                        label: item,
                                        value: item
                                    }
                                }));
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(textStatus);
                            }
                        });
                    }
                },
                select: function (e, ui) {
                    var value = ui.item.value;
                    $("#<%=txtWhat.ClientID %>").val(value);
                    if (e.keyCode == 13) {
                        $('ul.ui-autocomplete').css("display", "none");
                        __doPostBack('<%=upJobsList.ClientID %>', 'blur');
                        return false;
                    }
                    e.preventDefault();
                },
                minLength: 0,
                scroll: true
            }).focus(function (e) {
                $(this).autocomplete("search", $(this).val());
            });
        }

        function SearchWhereText() {
            $("#<%=txtWhere.ClientID %>").autocomplete({
                //autoFocus: true,
                source: function (request, response) {
                    var txt = $("#<%=txtWhere.ClientID %>").val();
                    if (txt.length > 1) {
                        $.ajax({
                            url: "CategoryWiseJobSearch.aspx/GetAutoCompleteWhereData",
                            type: "POST",
                            dataType: "json",
                            contentType: "application/json; charset=utf-8",
                            cache: false,
                            async: false,
                            data: JSON.stringify({ txt: txt }),
                            dataFilter: function (data) { return data; },
                            success: function (data) {
                                response($.map(data.d, function(item) {
                                    return {
                                        label: item,
                                        value: item
                                    }
                                }));
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                alert(textStatus);
                            }
                        });
                    }
                },
                select: function (e, ui) {
                    var value = ui.item.value;
                    $("#<%=txtWhere.ClientID %>").val(value);
                    if (e.keyCode == 13) {
                        __doPostBack('<%=upJobsList.ClientID %>', 'blur');
                        $("#<%=txtWhere.ClientID %>").autocomplete('close');
                        return false;
                    }
                    e.preventDefault();
                },
                minLength: 0,
                scroll: true
            }).focus(function () {
                $(this).autocomplete("search", $(this).val());
            });
        }

        $(document).ready(function () {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(InIEvent);

            var prm = Sys.WebForms.PageRequestManager.getInstance();
            prm.add_endRequest(function (s, e) {
                var val = $('#<%=sortTypeVal.ClientID %>').val();
                if (val == '0')
                    $('.sort-by-level').html('Sort By: Relevance');
                else if (val == '1')
                    $('.sort-by-level').html('Sort By: Salary');
                else if (val == '2')
                    $('.sort-by-level').html('Sort By: Advertiser');
                else if (val == '3')
                    $('.sort-by-level').html('Sort By: Date');
                else if (val == '4')
                    $('.sort-by-level').html('Sort By: Closing Soon');
            });

            SearchWhatText();
            SearchWhereText();

            $(document).click(function (e) {
            });

            $('#<%=txtWhat.ClientID %>').live("blur", function (e) {
                $('ul.ui-autocomplete').addClass("display-none");
            });
            $('#<%=txtWhat.ClientID %>').live("keyup", function (e) {
                if ($(this).val().length < 2) {
                    $("#<%=txtWhat.ClientID %>").autocomplete('close');
                }
            });

            $('#<%=txtWhat.ClientID %>').live("keypress", function (e) {
                if (e.keyCode == 13) {
                    $('ul.ui-autocomplete').css("display", "none");
                    __doPostBack('<%=upJobsList.ClientID %>', 'blur');
                    return false;
                }
            });

            $('#<%=txtWhere.ClientID %>').live("keyup", function (e) {
                if ($(this).val().length < 2) {
                    $("#<%=txtWhere.ClientID %>").autocomplete('close');
                }
            });
            $('#<%=txtWhere.ClientID %>').live("keypress", function (e) {
                if (e.keyCode == 13) {
                    __doPostBack('<%=upJobsList.ClientID %>', 'blur');
                    $("#<%=txtWhere.ClientID %>").autocomplete('close');
                    return false;
                }
            });

            $('#<%=lnkRelivance.ClientID %>').live("click", function (e) {
                $('#<%=sortTypeVal.ClientID %>').val('0');
                return true;
            });
            $('#<%=lnkSalary.ClientID %>').live("click", function (e) {
                $('#<%=sortTypeVal.ClientID %>').val('1');
                return true;
            });
            $('#<%=lnkAdvertiser.ClientID %>').live("click", function (e) {
                $('#<%=sortTypeVal.ClientID %>').val('2');
                return true;
            });
            $('#<%=lnkDate.ClientID %>').live("click", function (e) {
                $('#<%=sortTypeVal.ClientID %>').val('3');
                return true;
            });
            $('#<%=lnkClosingSoon.ClientID %>').live("click", function (e) {
                $('#<%=sortTypeVal.ClientID %>').val('4');
                return true;
            });
        });

        function ExpandedCollapsedElements() {
            $(".category-header").click(function () {
                $header = $(this);
                //getting the next element
                $content = $header.next();
                //open up the content needed - toggle the slide- if visible, slide up, if not slidedown.
                $content.slideToggle(500, function () {
                    //execute this after slideToggle is done
                    //change text of header based on visibility of content div
                    $header.children().find(".expanded-collapsed").remove();
                    $header.children().prepend(function () {
                        //change text based on condition
                        if ($content.is(":visible")) {
                            return "<img class='expanded-collapsed' src='../images/collapsed.gif' />"
                        }
                        else {
                            return "<img class='expanded-collapsed' src='../images/expanded.gif' />";
                        }
                    });
                });
            });
        }

        function JobSummaryToolsTips() {
            var moveLeft = 20;
            var moveDown = 10;

            $('a#trigger').hover(function (e) {
                $(this).next().show();
            }, function () {
                $(this).next().hide();
            });

            $('div.trigger').hover(function (e) {
                $(this).children().find("#category-pop-up").show();
            }, function () {
                $(this).children().find("#category-pop-up").hide();
            });

            $('a#trigger').mousemove(function (e) {
                $(this).next().css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
            });

            $('div.trigger').mousemove(function (e) {
                $(this).children().find("#category-pop-up").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
            });
        }
    </script>

    <script type="text/javascript">
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(pageLoaded);
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(pageLoaded);

        function pageLoaded(sender, args) {
            window.scrollTo(0, 0);
        }
    </script>
    <input runat="server" type="hidden" id="sortTypeVal" value="0" />
    <div class="container" style="min-height: 1560px">
        <asp:UpdateProgress ID="UpdateProgress2" AssociatedUpdatePanelID="upJobsList" runat="server" DisplayAfter="1">
            <ProgressTemplate>
                <div class="divWaiting">
                    <img src="../Images/please_wait.gif" alt="Please wait..." />
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <asp:UpdatePanel ID="upJobsList" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <script type="text/javascript" language="javascript">
                    Sys.Application.add_load(ExpandedCollapsedElements);
                    Sys.Application.add_load(JobSummaryToolsTips);
                </script>

                <div class="edit-profile-float-nav">
                    <div class="left-panel-header">
                        Refine search result
                    </div>
                    <div class="left-righ-padding">
                        <div id="divRefineSearch" class="row job-list-search-input">
                            <div class="col-md-12">
                                <asp:TextBox ID="txtWhat" runat="server" AutoCompleteType="Disabled" CssClass="form-control" placeholder="What (Job Title, Company)"></asp:TextBox>
                            </div>
                            <div class="col-md-12">
                                <asp:TextBox ID="txtWhere" runat="server" AutoCompleteType="Disabled" CssClass="form-control" placeholder="Whare (City, State, Country)"></asp:TextBox>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12 category-header">
                                <h5>
                                    <img class='expanded-collapsed' src='../images/collapsed.gif' />
                                    Functional Categories</h5>
                            </div>
                            <div class="col-md-12 checkbox scroll-second checkbox-table">
                                <asp:CheckBox ID="chkAnyIndustryList" runat="server" Text="Any" AutoPostBack="true" OnCheckedChanged="chkAnyIndustryList_OnCheckedChanged" />
                                <asp:CheckBoxList ID="chkIndustryList" runat="server" Width="100%" AutoPostBack="true" OnSelectedIndexChanged="chkIndustryList_OnCheckedChanged">
                                </asp:CheckBoxList>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12 category-header">
                                <h5>
                                    <img class='expanded-collapsed' src='../images/collapsed.gif' />
                                    Industry</h5>
                            </div>
                            <div class="col-md-12 checkbox scroll-second checkbox-table content-list">
                                <asp:CheckBox ID="chkAnyCategoryList" runat="server" Text="Any" AutoPostBack="true" OnCheckedChanged="chkAnyCategoryList_OnCheckedChanged" />
                                <asp:CheckBoxList ID="chkCategoryList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="chkCategoryList_OnCheckedChanged">
                                </asp:CheckBoxList>
                            </div>
                        </div>


                        <div class="row">
                            <div class="col-md-12 category-header">
                                <h5>
                                    <img class='expanded-collapsed' src='../images/collapsed.gif' />
                                    Career Level</h5>
                            </div>
                            <div class="col-md-12 checkbox checkbox-table content-list">
                                <asp:CheckBox ID="chkAnyCareerLevelList" runat="server" Text="Any" AutoPostBack="true" OnCheckedChanged="chkAnyCareerLevelList_OnCheckedChanged" />
                                <asp:CheckBoxList ID="chkCareerLevelList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="chkCareerLevelList_OnCheckedChanged">
                                </asp:CheckBoxList>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12 category-header">
                                <h5>
                                    <img class='expanded-collapsed' src='../images/collapsed.gif' />
                                    Job Nature</h5>
                            </div>
                            <div class="col-md-12 checkbox checkbox-table">
                                <asp:CheckBox ID="chkAnyJobTypeList" runat="server" Text="Any" AutoPostBack="true" OnCheckedChanged="chkAnyJobTypeList_OnCheckedChanged" />
                                <asp:CheckBoxList ID="chkJobTypeList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="chkJobTypeList_OnCheckedChanged">
                                </asp:CheckBoxList>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12 category-header">
                                <h5>
                                    <img class='expanded-collapsed' src='../images/collapsed.gif' />
                                    Closing Date</h5>
                            </div>
                            <div class="col-md-12 checkbox posted-on">
                                <label>
                                    <asp:CheckBox ID="chkClosingDateAny" runat="server" Text="Any" AutoPostBack="true" OnCheckedChanged="chkClosingDateAny_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkClosingDateToday" runat="server" Text="Today" AutoPostBack="true" OnCheckedChanged="chkClosingDateToday_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkClosingDateTomorrow" runat="server" Text="Tomorrow" AutoPostBack="true" OnCheckedChanged="chkClosingDateToday_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkClosingDateNext5Days" runat="server" Text="Next 5 Days" AutoPostBack="true" OnCheckedChanged="chkClosingDateToday_OnCheckedChanged" /></label>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12 category-header">
                                <h5>
                                    <img class='expanded-collapsed' src='../images/collapsed.gif' />
                                    Posted On</h5>
                            </div>
                            <div class="col-md-12 checkbox posted-on">
                                <label>
                                    <asp:CheckBox ID="chkAnyTime" runat="server" Text="Any" AutoPostBack="true" OnCheckedChanged="chkAnyTime_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkYesterday" runat="server" Text="Yesterday" AutoPostBack="true" OnCheckedChanged="chkYesterday_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkTwoToSevenDays" runat="server" Text="2 to 7 days ago" AutoPostBack="true" OnCheckedChanged="chkYesterday_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkEightToForteenDays" runat="server" Text="8 to 14 days ago" AutoPostBack="true" OnCheckedChanged="chkYesterday_OnCheckedChanged" /></label>
                                <label>
                                    <asp:CheckBox ID="chkFifteenToThirtyDays" runat="server" Text="15 to 30 days ago" AutoPostBack="true" OnCheckedChanged="chkYesterday_OnCheckedChanged" /></label>
                            </div>
                        </div>

                        <div class="row text-center">
                            <span class="float-shadow">
                                <asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_OnClick" CssClass="btn btn-primary orange-gradiant float-shadow" />
                            </span>
                        </div>
                    </div>
                </div>
                <!-- Job add Row Start Here-->
                <div class="row top-margin">
                    <!-- Panel Container Start Here-->
                    <div class="panel panel-default job-list-view-panel">
                        <div class="panel-heading orange-gradiant">
                            <h3 class="panel-title">All Posted Jobs</h3>
                        </div>
                        <div class="panel-body">
                            <!--Bottom Pagination Start-->
                            <div class="row top-pagination">
                                <div class="col-md-3">
                                    <nav>
                                        <ul class="pager">
                                            <li>
                                                <a href="#">
                                                    <asp:Label runat="server" ID="lblPagingFromTo" Text="1-1"></asp:Label>
                                                    of About
                                                    <asp:Label runat="server" ID="lblTotalJobs" Text="150"></asp:Label></a>
                                            </li>
                                        </ul>
                                    </nav>
                                </div>
                                <div class="col-md-9 pull-right sort-by">
                                    <div class="col-md-3 sort-by-level">
                                        Sort By: Relevance
                                    </div>
                                    <!--Action Dropdown-->
                                    <div class="dropdown">
                                        <a href="#" class="dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
                                            <img src="../img/action-dropdown.png" width="22" height="22">
                                        </a>
                                        <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
                                            <li role="presentation">
                                                <asp:LinkButton role="menuitem" ID="lnkRelivance" runat="server" Text="Relevance" OnClick="SortMenu_OnClick"></asp:LinkButton>
                                            </li>
                                            <li role="presentation">
                                                <asp:LinkButton role="menuitem" ID="lnkSalary" runat="server" Text="Salary" OnClick="SortMenu_OnClick"></asp:LinkButton>
                                            </li>
                                            <li role="presentation">
                                                <asp:LinkButton role="menuitem" ID="lnkAdvertiser" runat="server" Text="Advertiser" OnClick="SortMenu_OnClick"></asp:LinkButton>
                                            </li>
                                            <li role="presentation">
                                                <asp:LinkButton role="menuitem" ID="lnkDate" runat="server" Text="Date" OnClick="SortMenu_OnClick"></asp:LinkButton>
                                            </li>
                                            <li role="presentation">
                                                <asp:LinkButton role="menuitem" ID="lnkClosingSoon" runat="server" Text="Closing Soon" OnClick="SortMenu_OnClick"></asp:LinkButton>
                                            </li>
                                        </ul>
                                    </div>
                                    <!--Action Dropdown-->
                                </div>
                            </div>
                            <!--Bottom Pagination End-->

                            <!--Job List Table-->
                            <div class="job-list-table">
                                <table class="table table-striped">
                                    <thead>
                                        <tr>
                                            <th class="title-header">Job Title/Company
                                            </th>
                                            <th class="title-publish">Location/Published
                                            </th>
                                            <th>Deadline
                                            </th>
                                        </tr>
                                    </thead>
                                </table>
                                <asp:DataList ID="gvJobsList" runat="server" RepeatColumns="1" RepeatLayout="Table" 
                                    CellSpacing="0" CellPadding="0" Width="100%" RepeatDirection="Vertical" CssClass="table table-striped table-hover">
                                    <ItemTemplate>
                                        <div class="trigger">
                                            <asp:HiddenField ID="txtJobID" runat="server" Value='<%# Helper.Base64Encode(Eval("JobID").ToString()) %>'></asp:HiddenField>
                                            <div id="divJobImage" class="job-image">
                                                <img src='<%# Eval("JobImagePath")%>' alt="" style="width: 70px; height: 60px;" />
                                            </div>
                                            <div id="divJobTitle" class="job-title">
                                                <h4>
                                                    <a href='../JobSeeker/JobDetails.aspx?jID=<%# Helper.Base64Encode(Eval("JobID").ToString()) %>' target="_blank" id="trigger">
                                                        <%# Eval("JobTitle")%>
                                                    </a>
                                                    <!-- HIDDEN / POP-UP DIV -->
                                                    <div id="category-pop-up">
                                                        <h4><%# Eval("JobTitle")%></h4>
                                                        <div class="row">
                                                            <div class="col-md-2 col-md-2-label">Company: </div>
                                                            <div class="col-md-2 col-md-2-value"><%# Eval("CompanyName")%></div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-md-2 col-md-2-label">Category:</div>
                                                            <div class="col-md-2 col-md-2-value"><%# Eval("JobCategory")%></div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-md-2 col-md-2-label">No. of Vacancy:</div>
                                                            <div class="col-md-2 col-md-2-value"><%# Eval("Vacancies")%></div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col-md-2 col-md-2-label">Salary:</div>
                                                            <div class="col-md-2 col-md-2-value">
                                                                <%# ((int)Eval("SalaryRange") == 2) ? (Eval("SalaryRangeMin")  + " - " + Eval("SalaryRangeMax") + " Npr/Month") : ((int)Eval("SalaryRange") == 1) ? "Don't want to mention" : "Negotiable" %>
                                                            </div>
                                                        </div>
                                                        </p>
                                                    </div>

                                                </h4>
                                                <p>
                                                    <%# Eval("CompanyName")%>
                                                </p>
                                            </div>
                                            <div id="divLocationPublished" class="location-published">
                                                <%# System.Web.HttpUtility.HtmlDecode((string)Eval("Location"))%>
                                                <span class="application-deadline">
                                                    <%# Eval("PostedDate", "{0:dd.MM.yyyy}")%></span>
                                            </div>
                                            <div id="divDeadline" class="deadline">
                                                <span class="deadline-sticker">
                                                    <%# Eval("Deadline")%> Days
                                                </span>
                                            </div>
                                        </div>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        <asp:Label  Visible='<%#bool.Parse((gvJobsList.Items.Count==0).ToString())%>' runat="server" ID="lblNoRecord" CssClass="leftMarginForEmptyMessage" Text="No data found!" Font-Bold="true" ForeColor="Red"></asp:Label>
                                    </FooterTemplate>
                                </asp:DataList>
                            </div>
                            <!--Job List Table-->

                            <!--Bottom Pagination Start-->
                            <div class="row bottom-pagination-custom">
                                <div class="col-md-8">
                                    <nav>
                                        <ul class="pagination">
                                            <li>
                                                <asp:PlaceHolder ID="PageLinksPrevious" runat="server"></asp:PlaceHolder>
                                            </li>
                                            <li>
                                                <asp:PlaceHolder ID="PageLinks" runat="server"></asp:PlaceHolder>
                                            </li>
                                            <li>
                                                <asp:PlaceHolder ID="PageLinksNext" runat="server"></asp:PlaceHolder>
                                            </li>
                                        </ul>
                                    </nav>
                                </div>

                                <div class="col-md-4 page-count ">
                                    <div class="btn-group">
                                        <asp:DropDownList ID="ddlPage" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlPage_OnSelectedIndexChanged" CssClass="formddl page-dropdown">
                                            <asp:ListItem Text="20" Value="20"></asp:ListItem>
                                            <asp:ListItem Text="30" Value="30"></asp:ListItem>
                                            <asp:ListItem Text="40" Value="40"></asp:ListItem>
                                        </asp:DropDownList>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <!--Bottom Pagination End-->
                    </div>
                    <!-- Panel Body Start Here-->
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
</asp:Content>
